<div class="wrap">
<table class="widefat">
	<thead>
	<tr>
		<th scope="col"></th>
		<th scope="col"></th>
		<th scope="col"></th>
		<th scope="col"><div style="text-align: center;">Date</div></th>
		<th scope="col"></th>
		<th scope="col"></th>
		<th scope="col"></th>
		<th scope="col">Title</th>	
		<th scope="col"></th>
		<th scope="col"></th>
		<th scope="col">Link</th>
	</tr>
	</thead>
	<tbody id="the-list">

<?php 

require_once('../../../wp-load.php');
$keyword =   esc_html($_POST["keyword"]);

global $wpdb;
if($keyword){
echo "<strong>Search results for:</strong> ";
echo $keyword;
}
else {
echo"All problems";
}

$all_problems =  $wpdb->get_results($wpdb->prepare("SELECT ID, title, url, date_created FROM {$wpdb->prefix}scope  WHERE title LIKE '%%%s%%' OR name LIKE '%%%s%%' OR email LIKE '%%%s%%' OR problem LIKE '%%%s%%' ORDER BY ID", $keyword,$keyword,$keyword,$keyword));

if (count($all_problems)) {
	
	foreach($all_problems as $scope) {
	//	$class = ('alternate' == $class) ? '' : 'alternate';
		//print "<tr id='scope-{$scope->ID}' class='$class'>\n";
		?>
<td>
		<form method=post name="viewForm" id="viewForm" action="http://umbcs.org/scope/wp-content/plugins/scope/view_problem.php">
			<input type="submit" id="submit" value="View"/> 
			<input type="hidden"  name="ID" id="ID" readonly="readonly" value="<?php echo $scope->ID?>" maxlength="10" size="3"/> 
</form>		
</td>
		<td>    </td>
		<td>    </td>		
<td><?php echo date(get_option('date_format') . ' ' . get_option('time_format'), strtotime($scope->date_created)) ?></td>
		<td>    </td>
		<td>    </td>
		<td>    </td>
		<th scope="row" style="text-align: left;"><?php echo $scope->title ?></th>
		<td>    </td>
		<td>    </td>		
		<td><a href="<?php echo $scope->url ?>"  target="_blank"><?php echo $scope->url ?></a></td>	

		</tr>
<?php
		}
	} else {
?>
	<tr>
		<td colspan="4"><?php echo 'Sorry, but nothing matched your search criteria. Please try again with some different keywords.'; ?></td>
	</tr>
<?php
}
?>	
	</tbody>
</table>
<br /><br />
<a href="javascript: history.go(-1)">Back</a>
